﻿<?php
/**
 * DESCRIPTION:
 *  database interaction is here
 * METHODS:
 *  boolean connect($host='localhost', $port='3306', $user='root', $password='', $db='php_muscls') makes a connection
 * ======
 * @author at8eqeq3
 * @version 0.1
 */

function connect($host=DB_HOST, $port=DB_PORT, $user=DB_USER, $password=DB_PASS, $db=DB_NAME){
    if(@mysql_connect($host.':'.$port, $user, $password)){
        if(@mysql_select_db($db)){
            return true;
        }else{
            $e = new error(__FILE__, __LINE__, "Не удалось подключиться к базе <b>$db</b>", true);
            $e->raise();
        }
    }else{
        $e = new error(__FILE__, __LINE__, "Не удалось подключиться к серверу <b>$host:$port</b>", true);
        $e->raise();
    }
}

//no way to use this script apart from app
global $up_and_running;
if(!isset($up_and_running) || $up_and_running == false){
    echo 'from '.__FILE__.':<br />';
    echo '<b><font size="7">TITS OR GTFO!!!</font></b>'; //better to change this string ;)
}
?>